package org.seckill.TestAop;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * Created by wangyg 
 * on 2017/4/19 16:59
 */
public class ProxyHandler implements InvocationHandler {
	private Object target;

	public Object bind(Object obj) {
		this.target = obj;
		return Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(), this);
	}

	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println("前置消息");
		Object invoke = method.invoke(this.target, args);
		System.out.println("后置消息");
		return invoke;
	}
}
